package com.piece.admin.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@NoArgsConstructor
@Table(name = "oauth_client_details")
@ApiModel(value = "应用授权表:oauth_client_details")
public class OauthClientDetails implements Serializable {

    @Id
    @Column(name = "client_id", length = 32)
    @ApiModelProperty(value = "应用标识")
    private String clientId;

    @Column(name = "client_name", length = 128)
    @ApiModelProperty(value = "应用名称")
    private String clientName;

    @Column(name = "resource_ids", length = 256)
    @ApiModelProperty(value = "资源限定串", notes = "逗号分割")
    private String resourceIds;

    @Column(name = "client_secret", length = 256)
    @ApiModelProperty(value = "应用密钥", notes = "(bcyt) 加密")
    private String clientSecret;

    @Column(name = "client_secret_str", length = 256)
    @ApiModelProperty(value = "应用密钥", notes = "明文")
    private String clientSecretStr;

    @Column(name = "scope", length = 256)
    @ApiModelProperty(value = "范围")
    private String scope;

    @Column(name = "authorized_grant_types", length = 256)
    @ApiModelProperty(value = "授权方式", notes = "authorization_code,password,refresh_token,client_credentials")
    private String authorizedGrantTypes;

    @Column(name = "web_server_redirect_uri", length = 256)
    @ApiModelProperty(value = "回调地址")
    private String webServerRedirectUri;

    @Column(name = "authorities", length = 256)
    @ApiModelProperty(value = "权限")
    private String authorities;

    @Column(name = "access_token_validity", length = 11)
    @ApiModelProperty(value = "access_token有效期")
    private Integer accessTokenValidity;

    @Column(name = "refresh_token_validity", length = 11)
    @ApiModelProperty(value = "refresh_token有效期")
    private Integer refreshTokenValidity;

    @Column(name = "additional_information")
    @ApiModelProperty(value = "附加信息")
    private String additionalInformation;

    @Column(name = "autoapprove", length = 4)
    @ApiModelProperty(value = "是否自动授权", notes = "默认 true")
    private String autoapprove;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date createTime;

    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date updateTime;
}
